package ch.bfh.medinfo.javafx.dice.implementation;

import java.util.Arrays;

import ch.bfh.medinfo.javafx.dice.definition.StatisticalDice;

/**
 * Implements a dice which is using the inner mechanism of Java to have a fair randomness for a simple dice game.
 * Please note: This implementation is not suitable for security related things such as games involving money...
 * @author reto
 *
 */
public class StatisticalFairDice extends FairDice implements StatisticalDice {
	private int[] statistics;

	/**
	 * 
	 * @param minValue
	 * @param maxValue
	 */
	public StatisticalFairDice(int minValue, int maxValue) {
		super(minValue,maxValue);
	}
	@Override
	protected void initialize(){
		this.statistics=new int[Math.abs(getMaxValue()-getMinValue())+1];
		super.initialize();
	}

	@Override
	public void play() {
		super.play();
		
		//update the statistics
		this.statistics[Math.abs(this.getActualValue()-this.getMinValue())]++;
	}
		
	public int[] getStatistics() {
		return Arrays.copyOf(statistics,statistics.length);
	}

}
